home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 August / maximum-cd-2010-08.iso / DiscContents / AutoHotkey104805_Install.exe / Extras / Editors / TextPad / Run this to install syntax and clip library files for TextPad.ahk < prev   
Encoding:
Text File  |  2009-04-06  |  7.4 KB  |  163 lines

  1. ; Done by Rajat for AutoHotkey
  2. ;
  3. ; Script Function:
  4. ;    Install syntax highlighting and clip library files.
  5. ;    Add hotkeys to TextPad for Launching Script and Context Sensitive Help
  6.  
  7. ; April 06, 2009
  8. ; - Support Textpad 5 (in addition to 4) [TheDaniel (tauroxian@yahoo.com)]
  9.  
  10. ; August 29, 2006
  11. ; - Uses A_AhkPath as a new fallback method to find where AutoHotkey is installed.
  12.  
  13. ; June 2, 2005:
  14. ; - Uses a different method to find where AutoHotkey is installed.
  15. ; - Avoids using SetWorkingDir so that this script can be started in any directory.
  16. ; - Improved the "Run script" shortcut to use ErrStdOut on Windows NT/2k/XP or later.
  17. ; - Added a simple GUI to prompt for extra options at the end of the installation.
  18.  
  19.  
  20. ; Discover where AutoHotkey and its related files reside:
  21. RegRead, AhkDir, HKLM, SOFTWARE\AutoHotkey, InstallDir
  22. if (ErrorLevel or not FileExist(AhkDir . "\AutoHotkey.exe"))  ; Not found, so try best-guess instead.
  23.     SplitPath, A_AhkPath,, AhkDir
  24.  
  25. Loop, HKEY_CURRENT_USER, Software\Helios\TextPad 5, 1
  26. {
  27.     TextPadVersion = 5
  28.     break
  29. }
  30. if not TextPadVersion
  31. {
  32.     Loop, HKEY_CURRENT_USER, Software\Helios\TextPad 4, 1
  33.     {
  34.         TextPadVersion = 4
  35.         break
  36.     }
  37. }
  38. if not TextPadVersion
  39.     TextPadVersion = 5  ; Fall back to the default.
  40.  
  41. ; Get path to TextPad:
  42. RegRead, TextPadDir, HKEY_CLASSES_ROOT, TextPad.tws\shell\open\Command,
  43. if TextPadDir =
  44.     RegRead, TextPadDir, HKEY_CLASSES_ROOT, Applications\TextPad.exe\shell\edit\Command,
  45. if TextPadDir =
  46.     TextPadDir = %A_ProgramFiles%\TextPad %TextPadVersion%  ; Try a best-guess location.
  47. else
  48. {
  49.     StringReplace, TextPadDir, TextPadDir, ", , all  ; Remove all double quotes.
  50.     SplitPath, TextPadDir, , TextPadDir
  51. }
  52. IfNotExist, %TextPadDir%
  53. {
  54.     MsgBox, TextPad could not be found (the directory "%TextPadDir%" does not exist).`n`nThis script will now exit.
  55.     ExitApp
  56. }
  57.  
  58. Gui -SysMenu
  59. Gui, Font, s12
  60. Gui, Add, Text, , This script will install syntax highlighting and clip library files for TextPad v%TextPadVersion%.`nSelect any extra options you want enabled:
  61. Gui, Font, s10
  62. Gui, Add, Checkbox, checked vDefaultEditor, Make TextPad the default editor for AutoHotkey scripts.
  63. Gui, Font, cRed
  64. Gui, Add, Text, y+20, Warning:%A_Space%
  65. Gui, Font, cDefault
  66. Gui, Add, Text, x+0, If you have any custom tool items in your TextPad Tools menu,`nchecking any of the following might replace/overwrite them.
  67. Gui, Add, Checkbox, vShortcutRun xm, Make 'Ctrl+1' a shortcut for running the script currently loaded in TextPad.
  68. Gui, Add, Checkbox, vShortcutHelp, Make 'Ctrl+2' a shortcut for AutoHotkey context sensitive help in TextPad.
  69. Gui, Add, Checkbox, vShortcutIntelliSense, Make 'Ctrl+3' a shortcut for starting AutoHotkey IntelliSense in TextPad.
  70. Gui, Add, Text, , Note: The shortcut keys above can be changed in TextPad 'Configure Menu > Preferences > KeyBoard'
  71. Gui, Add, Button, y+20 w100 Default, &Install
  72. Gui, Add, Button, x+20 wp, &Cancel
  73. Gui, Show, , Configure TextPad for AutoHotkey
  74. return
  75.  
  76.  
  77.  
  78. GuiEscape:
  79. GuiClose:
  80. ButtonCancel:
  81. ExitApp
  82.  
  83.  
  84.  
  85. ButtonInstall:
  86. Gui Submit
  87. ExtrasPath = %AhkDir%\Extras\Editors\TextPad
  88.  
  89. FileCopy, %ExtrasPath%\AutoHotkey.syn, %TextPadDir%\system, 1
  90. if ErrorLevel <> 0
  91. {
  92.     MsgBox, Could not copy %ExtrasPath%\AutoHotkey.syn
  93.     ExitApp
  94. }
  95. FileCopy, %ExtrasPath%\AutoHotkey.tcl, %TextPadDir%\Samples, 1
  96. if ErrorLevel <> 0
  97. {
  98.     MsgBox, Could not copy %ExtrasPath%\AutoHotkey.tcl
  99.     ExitApp
  100. }
  101.  
  102. ; Now write the reg keys (use the non-abbreviated root key names in case user has an older version of AutoHotkey)
  103. RegTarget = Software\Helios\TextPad %TextPadVersion%
  104.  
  105. RegWrite, REG_DWORD, HKEY_CURRENT_USER, %RegTarget%\Document Classes\AutoHotkey, Type, 2
  106. RegWrite, REG_MULTI_SZ, HKEY_CURRENT_USER, Software\Helios\TextPad 4\Document Classes\AutoHotkey, Members, *.ahk
  107. RegWrite, REG_BINARY, HKEY_CURRENT_USER, %RegTarget%\Document Classes\AutoHotkey, Properties, 46000000010000000100000001000000
  108. RegWrite, REG_BINARY, HKEY_CURRENT_USER, %RegTarget%\Document Classes\AutoHotkey, Colors, 010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000008006c800010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000008080800001000000
  109. RegWrite, REG_BINARY, HKEY_CURRENT_USER, %RegTarget%\Document Classes\AutoHotkey, SyntaxProps, 01000000
  110. Regwrite, REG_BINARY, HKEY_CURRENT_USER, %RegTarget%\Document Classes\AutoHotkey,TabStops,00000000000000000400040000000000406CB800C40306004AD85000FFFFFFFF18EE1200C805B80000010000FE32470018EE12008D000000C805B800904E1500E803B80044EE12000000000078DD4F0018EE120001000000E803B800ACF91200BE02050001000000E803B8008D00000001000000ACF9120000000000904E150008EE120004F41200CFE7520000000000
  111. RegWrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Document Classes\AutoHotkey, SyntaxFile, AutoHotkey.syn
  112. RegWrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Document Classes\AutoHotkey, WordChars, _
  113.  
  114. if DefaultEditor = 1
  115.     RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Edit\Command, , "%TextPadDir%\TextPad.exe" "`%1"
  116.  
  117. if ShortcutRun = 1
  118. {
  119.     ; Tried using the following, but it doesn't seem to add much value in TextPad because unlike EditPlus,
  120.     ; it put the caret/focus to the line indicated in the syntax error message.  In other words, the standard
  121.     ; syntax-error dialog is probably more useful since it doesn't open a secondary TextPad window containing
  122.     ; the results of every script launch:
  123.     ; Command: %comspec%
  124.     ; Parameters: /c ""%AhkDir%\AutoHotkey.exe" /ErrorStdOut "$File""
  125.     RegWrite, REG_BINARY, HKEY_CURRENT_USER, %RegTarget%\Tools\0, Properties, 000000005680000044000000
  126.     RegWrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\0, MenuText, Run Script
  127.     RegWrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\0, Command, %AhkDir%\AutoHotkey.exe
  128.     RegWrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\0, Parameters, "$File"
  129.     RegWrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\0, Folder, $FileDir
  130.     RegWrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\0, RE,
  131. }
  132.  
  133.  
  134. if ShortcutHelp = 1
  135. {
  136.     RegWrite, REG_BINARY, HKEY_CURRENT_USER, %RegTarget%\Tools\1, Properties, 020000005780000004000000
  137.     RegWrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\1, MenuText, AutoHotkey Help
  138.     RegWrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\1, Command, HH.EXE
  139.     RegWrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\1, Parameters, %AhkDir%\AutoHotkey.chm
  140.     RegWrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\1, Folder,
  141.     RegWrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\1, RE,
  142. }
  143.  
  144.  
  145. if ShortcutIntelliSense = 1
  146. {
  147.     Regwrite, REG_BINARY, HKEY_CURRENT_USER, %RegTarget%\Tools\2, Properties, 000000005880000044000000
  148.     Regwrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\2, MenuText, IntelliSense for AutoComplete
  149.     Regwrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\2, Command, %AhkDir%\AutoHotkey.exe
  150.     Regwrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\2, Parameters, "%TextPadDir%\system\IntelliSense.ahk"
  151.     Regwrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\2, Folder, $FileDir
  152.     Regwrite, REG_SZ, HKEY_CURRENT_USER, %RegTarget%\Tools\2, RE,
  153.  
  154.     FileCopy, %AhkDir%\Extras\Scripts\IntelliSense.ahk, %TextPadDir%\system, 1
  155.     FileCopy, %AhkDir%\Extras\Editors\Syntax\Commands.txt, %TextPadDir%\system\AHKCommands.txt, 1
  156. }
  157.  
  158. SplashTextOn,,, Installation Complete
  159. Sleep 2000
  160. SplashTextOff
  161.  
  162. ExitApp  ; Must do this since GUI scripts are persistent.
  163.